//主体内容左侧菜单折叠
layui.use(['tree', 'util'], function() {
	var tree = layui.tree,
		layer = layui.layer,
		util = layui.util,
		data1 = [{
			title: '安亭鎮',
			id: 1,
			children: [{
					title: '安亭镇综合为老服务中心',
					id: 1000,
					children: [{
						title: '安亭',
						id: 10001
					}, {
						title: '黄渡',
						id: 10002
					}, {
						title: '方泰',
						id: 10003
					}, ]
				}, {
					title: '安亭镇综合为老服务中心2',
					id: 1000,
					children: [{
						title: '安亭2',
						id: 10001
					}, {
						title: '黄渡2',
						id: 10002
					}, {
						title: '方泰2',
						id: 10003
					}, ]
				},
				/*, {
										title: '九江',
										id: 1001
									}, {
										title: '赣州',
										id: 1002
									}*/
			]
		}, {
			title: '村、社区',
			id: 2,
			children: [{
					title: '安亭镇综合为老服务中心',
					id: 2000,
					children: [{
						title: '安亭社区',
						id: 20001
					}, {
						title: '六泉桥社区',
						id: 20002
					}, {
						title: '金桂社区',
						id: 20003
					}, {
						title: '沁乐社区',
						id: 20004
					}, {
						title: '墨玉社区',
						id: 20005
					}, {
						title: '博园社区',
						id: 20006
					}, {
						title: '新安社区',
						id: 20007
					}, {
						title: '新源社区',
						id: 20008
					}]
				}
				/*, {
										title: '九江',
										id: 1001
									}, {
										title: '赣州',
										id: 1002
									}*/
			]
		}, {
			title: '黄渡片',
			id: 3,
			children: [{
				title: '新源社区1',
				id: 3000,
				children: [{
					title: '新源社区11',
					id: 30001,
				}, {
					title: '新源社区22',
					id: 30002,
				}]
			}]
		}, {
			title: '方泰片',
			id: 4,
			children: [{
				title: '新源社区1',
				id: 4000,
				children: [{
					title: '新源社区11',
					id: 40001,
				}, {
					title: '新源社区22',
					id: 40002,
				}]
			}]
		}]
	//无连接线风格
	tree.render({
		elem: '#test13',
		data: data1,
		showLine: false //是否开启连接线
			,
		click: function(obj) {
			var entray = $("div.layui-tree-entry");
			var main = $("div.layui-tree-main");
			if($(obj.elem).children("div.layui-tree-pack").children("div.layui-tree-set").children(entray).children(main).find("span").length <= 0) {
				$(entray).removeClass("current");
				$(obj.elem).children(entray).addClass("current");
			}
			if(obj.state == "open") {
				$(obj.elem).children(entray).children(main).find('span').find('i').removeClass('layui-tree-iconArrow').addClass('layui-tree-iconArrow-cur');
			} else {
				$(obj.elem).children(entray).children(main).find('span').find('i').removeClass('layui-tree-iconArrow-cur').addClass('layui-tree-iconArrow');
			}
		}
	});

});